<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
 <meta>
  <!-- Stylesheets -->
  <link href="../web.css" type="text/css" rel="stylesheet"></link>
  <link href="../pygmentize.css" type="text/css" rel="stylesheet"></link>
  <title>VLFeat - Documentation - C API</title>
  <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>

  <!-- Scripts-->
  
 </meta>

 <!-- Body Start -->
 <body>
  <div id="header">
   <!-- Google CSE Search Box Begins -->
   <form action="http://www.vlfeat.org/search.html" method="get" id="cse-search-box" enctype="application/x-www-form-urlencoded">
    <div>
     <input type="hidden" name="cx" value="003215582122030917471:oq23albfeam"></input>
     <input type="hidden" name="cof" value="FORID:11"></input>
     <input type="hidden" name="ie" value="UTF-8"></input>
     <input type="text" name="q" size="31"></input>
     <input type="submit" name="sa" value="Search"></input>
    </div>
   </form>
   <script src="http://www.google.com/coop/cse/brand?form=cse-search-box&amp;lang=en" xml:space="preserve" type="text/javascript"></script>
   <!-- Google CSE Search Box Ends -->
   <h1><a shape="rect" href="../index.html" class="plain"><span id="vlfeat">VLFeat</span><span id="dotorg">.org</span></a></h1>
  </div>
  <div id="headbanner">
   Documentation - C API
  </div>
  <div id="pagebody">
   <div id="sidebar"> <!-- Navigation Start -->
    <ul>
<li><a href="../index.html">Home</a>
</li>
<li><a href="../download.html">Download</a>
</li>
<li><a href="../doc.html">Documentation</a>
<ul>
<li><a href="../mdoc/mdoc.html">Matlab API</a>
</li>
<li><a href="index.html" class='active' >C API</a>
</li>
<li><a href="../man/man.html">Man pages</a>
</li>
</ul></li>
<li><a href="../overview/tut.html">Tutorials</a>
</li>
<li><a href="../applications/apps.html">Applications</a>
</li>
</ul>

   </div> <!-- sidebar -->
   <div id="content">
    
    <link rel="stylesheet" type="text/css" href="../doxygen.css"></style>
    <div class="doxygen">
<div>
<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Preprocssor, library state, etc. </div>  </div>
</div>
<div class="contents">
<div class="textblock"><dl class="author"><dt><b>Author:</b></dt><dd>Andrea Vedaldi</dd></dl>
<p><a class="el" href="generic_8h.html">generic.h</a> provides the following functionalities:</p>
<ul>
<li><a class="el" href="generic.html#generic-preproc">C preprocessor helpers</a></li>
<li><a class="el" href="generic.html#generic-state">VLFeat state and configuration parameters</a></li>
<li><a class="el" href="generic.html#generic-error">Error handling</a></li>
<li><a class="el" href="generic.html#generic-memory">Memory allocation</a></li>
<li><a class="el" href="generic.html#generic-logging">Logging</a></li>
<li><a class="el" href="generic.html#generic-time">Measuring time</a></li>
</ul>
<h2><a class="anchor" id="generic-preproc"></a>
C preprocessor helpers</h2>
<p>VLFeat provides a few C preprocessor macros of general utility. These include stringification (<a class="el" href="host_8h.html#a61a48096b951544d0554b8a06aa59306" title="Convert the argument to a string.">VL_STRINGIFY</a>, <a class="el" href="host_8h.html#a2a5d283f40e6bf0fc1ca74644084a423" title="Expand and then convert the argument to a string.">VL_XSTRINGIFY</a>) and concatenation (<a class="el" href="host_8h.html#aeba7ee97f4e6474a78c242ca9c49798c" title="Concatenate two arguments into a lexical unit.">VL_CAT</a>, <a class="el" href="host_8h.html#a755f8d9673970b82ad9375e32d2693ef" title="Expand and then concatenate two arguments into a lexical unit.">VL_XCAT</a>) of symbols.</p>
<h2><a class="anchor" id="generic-state"></a>
VLFeat state and configuration parameters</h2>
<p>VLFeat has some global configuration parameters that can changed. Changing the configuration is thread unsave (<a class="el" href="design.html#design-threads">Multi-threading</a>). Use <a class="el" href="generic_8h.html#a3fb6cee731450d886e49da54e29788e8" title="Toggle usage of SIMD instructions.">vl_set_simd_enabled</a> to toggle the use of a SIMD unit (Intel SSE code), <a class="el" href="generic_8h.html#ac04fe278ac908fa6ed02bda099588cf0" title="Set memory allocation functions.">vl_set_alloc_func</a> to change the memory allocation functions, and <a class="el" href="generic_8h.html#a17ef7f5dfc74e0ff032f46617a5bc1c5" title="Set printf function.">vl_set_printf_func</a> to change the logging function.</p>
<h2><a class="anchor" id="generic-error"></a>
Error handling</h2>
<p>Some VLFeat functions signal errors in a way similar to the standard C library. In case of error, a VLFeat function may return an error code directly, or an invalid result (for instance a negative file descriptor or a null pointer). Then <a class="el" href="generic_8h.html#ac1a9bdc5e32a00ca28599b8daf5e0d50" title="Get VLFeat last error code.">vl_get_last_error</a> and <a class="el" href="generic_8h.html#adf40d994cf9e6bbbc6c7dc92b3865882" title="Get VLFeat last error message.">vl_get_last_error_message</a> can be used to retrieve further details about the error (these functions should be used right after an error has occurred, before any other VLFeat call).</p>
<h2><a class="anchor" id="generic-memory"></a>
Memory allocation</h2>
<p>VLFeat uses the <a class="el" href="generic_8h.html#a136474bd173eb04e98989c7a521d4ada" title="Call customizable malloc function.">vl_malloc</a>, <a class="el" href="generic_8h.html#a6213d08692fb90f0a0eaa423644f25c2" title="Call customizable resize function.">vl_realloc</a>, <a class="el" href="generic_8h.html#a175a5268fe40a4e3c68e6fab63ed064b" title="Call customizable calloc function.">vl_calloc</a> and <a class="el" href="generic_8h.html#ae070a0a4d3d367a1ba8308644c88ada3" title="Call customizable free function.">vl_free</a> functions to allocate memory. Normally these functions are mapped to the underlying standard C library implementations. However <a class="el" href="generic_8h.html#ac04fe278ac908fa6ed02bda099588cf0" title="Set memory allocation functions.">vl_set_alloc_func</a> can be used to map them to other implementations. For instance, in MATALB MEX files these functions are mapped to the MATLAB equivalent which has a garbage collection mechanism to cope with interruptions during execution.</p>
<h2><a class="anchor" id="generic-logging"></a>
Logging</h2>
<p>VLFeat uses the macros <a class="el" href="generic_8h.html#a1d4b7e68329e078b0d9064b7f408c96b" title="Same as VL_PRINTF (legacy code)">VL_PRINT</a> and <a class="el" href="generic_8h.html#af68d1c6327bf2226b15c84007eab3d94" title="Call user-customizable printf function.">VL_PRINTF</a> to print progress or debug informations. These functions are normally mapped to the <code>printf</code> function of the underlying standard C library. However <a class="el" href="generic_8h.html#a17ef7f5dfc74e0ff032f46617a5bc1c5" title="Set printf function.">vl_set_printf_func</a> can be used to map it to a different implementation. For instance, in MATLAB MEX files this function is mapped to <code>mexPrintf</code>. Setting the function to <code>NULL</code> disables logging.</p>
<h2><a class="anchor" id="generic-time"></a>
Measuring time</h2>
<p>VLFeat provides <a class="el" href="generic_8h.html#a0eb9d2de6dc4cb6570db6bb3e8c39244" title="Reset processor time reference The function resets VLFeat TIC/TOC time reference.">vl_tic</a> and <a class="el" href="generic_8h.html#a6570090509ab5a156a24e2bbd082590d" title="Get elapsed time since tic.">vl_toc</a> as an easy way of measuring elapsed time. </p>
</div></div>
     <!-- Doc Here -->
    </div>
   
   </div>
   <div class="clear">&nbsp;</div>
  </div> <!-- pagebody -->
  <div id="footer">
   &copy; 2007-12 Andrea Vedaldi and Brian Fulkerson
  </div> <!-- footer -->

  <!-- Google Analytics Begins -->
  <script xml:space="preserve" type="text/javascript">
   //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {
   var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
   document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
   }
   //]]>
  </script>
  <script xml:space="preserve" type="text/javascript">
    //<![CDATA[
    var localre = /vlfeat.org/;
    if(document.location.host.search(localre) != -1)
    {

   try {
   var pageTracker = _gat._getTracker("UA-4936091-2");
   pageTracker._trackPageview();
   } catch(err) {}

   }
   //]]>
  </script>
  <!-- Google Analytics Ends -->
 </body>
</html>

 
